package com.example.entity;

import lombok.Data;
import java.time.LocalDateTime;

@Data
public class User {
    private Long id;
    
    private String username;
    
    private String password;
    
    private String nickname;
    
    private String email;
    
    private String phone;
    
    private String avatar; // 用户头像URL
    
    private Integer status; // 0-禁用 1-启用
    
    private String memberLevel; // 会员等级：NORMAL-普通用户，VIP3-三级会员，VIP2-二级会员，VIP1-一级会员
    
    private LocalDateTime createTime;
    
    private LocalDateTime updateTime;
    
    private Integer deleted;

    // 便捷方法
    public boolean isEnabled() {
        return this.status != null && this.status == 1;
    }

    public boolean isLocked() {
        return this.status != null && this.status == 0;
    }

    public void setEnabled(boolean enabled) {
        this.status = enabled ? 1 : 0;
    }

    public void setLocked(boolean locked) {
        this.status = locked ? 0 : 1;
    }

    // 会员等级相关方法
    public String getMemberLevelName() {
        if (memberLevel == null || "NORMAL".equals(memberLevel)) {
            return "普通用户";
        }
        switch (memberLevel) {
            case "VIP3":
                return "三级会员";
            case "VIP2":
                return "二级会员";
            case "VIP1":
                return "一级会员";
            default:
                return "普通用户";
        }
    }

    public boolean isVip() {
        return memberLevel != null && memberLevel.startsWith("VIP");
    }

    public boolean isVip1() {
        return "VIP1".equals(memberLevel);
    }

    public boolean isVip2() {
        return "VIP2".equals(memberLevel);
    }

    public boolean isVip3() {
        return "VIP3".equals(memberLevel);
    }
}